<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
{insert name="module_cssjs" css="core.css" js="jquery.min.js;top.js"}
</head>
{literal}
<style>
.platform-box {
	margin-bottom: 10px;
}
.role {
	height: 30px;
	line-height: 30px;
	padding-left: 20px;
}
.platform {
	margin-top: 10px;
	border: 1px solid #6ab6b6;
}
.platform .title {
	background-color: #6ab6b6;
	color: #fff;
	height: 30px;
	line-height: 30px;
	padding-left: 10px;
}
.platform .list{
	padding: 5px 10px 0 10px;
}
.TB-node {
	width: 100%;
	margin-bottom: 5px;
	border: 1px solid #6ab6b6;
}
.TB-node caption {
	text-align: left;
	height: 30px;
	line-height: 30px;
}
</style>
<script type="text/javascript">
$(document).ready(function() {

$('[name="selectAll"]').click(function() {
	var id = $(this).val();
	$('input[type="checkbox"]', '#list-'+id).prop("checked", $(this).prop('checked'));
});

$('[name="form"]').submit(function() {
	var roleId = $('input[name="roleId"]').val();
	if(!roleId) {
		alert('未知角色'); return false;
	}
	var params = $('[name="nodeId[]"]').serialize();
	params = params+'&roleId='+roleId;
	$.post('/rbac/role/node.json', params, function(dt) {
		if(dt.status) {
			alert(dt.message);
		} else {
			window.location.href = '/rbac/role/';
		}
	}, 'json')
	return false;
});
})
</script>
{/literal}
<body>
<h3 class="label">
	<strong class="on"><span>角色分配节点</span></strong>
	<span class="refresh"><a href="javascript:history.go(-1);">返回</a></span>
	<span class="refresh"><a href="">刷新</a></span>
</h3>
<div class="table">
	<form name="form" action="post">
	<input name="roleId" type="hidden" value="{$role.role_id}" />
	<div class="platform-box">
		<div class="role">角色名称：{$role.name}</div>
		{foreach key=key item=item from=$groupInfo}
		{if $item.pid == 0}
		<div class="platform">
			<div class="title">{$item.name}</div>
			<div class="list">
			{foreach key=k item=i from=$groupInfo}
			{if $i.pid == $item.gid}
			<table class="TB-node">
				<caption>{$i.name}：<input name="selectAll" type="checkbox" value="{$i.gid}" />全选</caption>
				<tr id="list-{$i.gid}">
					<td>
						{foreach key=_key item=_item from=$nodeInfo}{if $_item.gid == $i.gid}
						<input name="nodeId[]" type="checkbox" value="{$_item.node_id}" {if $nodes}{if in_array($_item.node_id, $nodes)}checked="checked"{/if}{/if} >{$_item.name}
						{/if}{/foreach}
					</td>
				</tr>
			</table>
			{/if}
			{/foreach}
			</div>
		</div>
		{/if}
		{/foreach}
	</div>
	<div class="btn-box">
		<span class="btn-indent"><input class="btn" type="submit" value="保&nbsp;&nbsp;存" /></span>
		<span class="btn-indent"><input class="btn" type="reset" value="重&nbsp;&nbsp;置" /></span>
	</div>
	</form>
</div>

</body>
</html>